/**
 *
 * Licensed Materials - Property of IBM 
 * 
 * OCO Source Materials 
 * 
 * (C) Copyright IBM Corp. 2011, 2012 All Rights Reserved 
 * 
 * The source code for this program is not published or other- 
 * wise divested of its trade secrets, irrespective of what has 
 * been deposited with the U.S. Copyright Office. 
 *
 */

/**
 * CHANGE HiSTORY:
 * Author             Time                 Description
 *
 */

package com.ibm.ba.demo.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ibm.ba.demo.service.ProductService;

/**
 * WorkloadController is to handle request related to workload.
 * 
 * @author Luyi
 */
@Controller
public class ProductController extends AbstractController {

	private static String PRODUCT_VIEW_NAME = "get_allProducts";
	private static Logger logger = Logger.getLogger(ProductController.class);
	
	@Autowired
	private ProductService productService;

	/**
	 * Map request URI - '/showAllProducts' to method - 'getAllProducts()'.
	 * Get the all products.
	 */
	@RequestMapping(value = "/showAllProducts", method = RequestMethod.GET)
	public String getAllProducts(ModelMap model) {
		logger.info("getAllProducts(ModelMap model) begin");
		model.addAttribute("allProducts", productService.getAllProducts());
		logger.info("getAllProducts(ModelMap model) end");
		return PRODUCT_VIEW_NAME;
	}
}
